<?php 
$f="facebox";
if(isset($_GET['aj'])){
$f="facebox1";
}
$currentPage = $_SERVER["PHP_SELF"];

$maxRows_rs_sublinks = 50;
$pg = 0;
if (isset($_GET['pg'])) {
  $pg = $_GET['pg'];
}
$startRow_rs_sublinks = $pg * $maxRows_rs_sublinks;


$rs_sublinks = getPageSettings($SITE_ID);
$row_rs_sublinks = mysql_fetch_assoc($rs_sublinks);

if (isset($_GET['tt'])) {
  $tt = $_GET['tt'];
} else {
  $all_rs_sublinks = getPageSettings($SITE_ID);
  $tt = mysql_num_rows($all_rs_sublinks);
}
$totalPages_rs_sublinks = ceil($tt/$maxRows_rs_sublinks)-1;

$queryString_rs_sublinks = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pg") == false && 
        stristr($param, "tt") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_rs_sublinks = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_rs_sublinks = sprintf("&tt=%d%s", $tt, $queryString_rs_sublinks);

if($tt>0){
?>

<table border="0">
  <tr>
    <td><?php if ($pg > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pg=%d%s", $currentPage, 0, $queryString_rs_sublinks); ?>">First</a>
      <?php } // Show if not first page ?></td>
    <td><?php if ($pg > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pg=%d%s", $currentPage, max(0, $pg - 1), $queryString_rs_sublinks); ?>">Previous</a>
      <?php } // Show if not first page ?></td>
    <td><?php if ($pg < $totalPages_rs_sublinks) { // Show if not last page ?>
        <a href="<?php printf("%s?pg=%d%s", $currentPage, min($totalPages_rs_sublinks, $pg + 1), $queryString_rs_sublinks); ?>">Next</a>
      <?php } // Show if not last page ?></td>
    <td><?php if ($pg < $totalPages_rs_sublinks) { // Show if not last page ?>
        <a href="<?php printf("%s?pg=%d%s", $currentPage, $totalPages_rs_sublinks, $queryString_rs_sublinks); ?>">Last</a>
        <?php } // Show if not last page ?></td>
    <td>&nbsp;
Records <?php echo ($startRow_rs_sublinks + 1) ?> to <?php echo min($startRow_rs_sublinks + $maxRows_rs_sublinks, $tt) ?> of <?php echo $tt ?></td>
  </tr>
</table>
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="allround" id="datatable">
  <tr>
    <th>categoryid</th>
    <th>categoryname</th>
    <th>&nbsp;</th>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_rs_sublinks['setting_name']; ?></td>
      <td><a href="?page=setting&amp;itemid=<?php echo $row_rs_sublinks['setting_name']; ?>" ><?php echo $row_rs_sublinks['setting_value']; ?></a></td>
      <td>&nbsp;</td>
    </tr>
    <?php } while ($row_rs_sublinks = mysql_fetch_assoc($rs_sublinks)); mysql_free_result($rs_sublinks); ?>
</table>
<?php } else { ?>
<div id="error">No setting Set</div>
<?php } ?>